package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
}

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

var ConfigData AppConfig

func Init() {
	viper.SetConfigFile("../../appconfig/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("读取配置文件失败")
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		panic("解析配置文件失败")
	}
	fmt.Println(ConfigData)
}
